package core.shiro;

import com.jfinal.plugin.activerecord.Db;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

/**
 * Created by Administrator on 2017/3/15.
 */
public class ShiroUtils {
    public static String getUserName(){
        return (String) SecurityUtils.getSubject().getPrincipal();
    }
    public static int getUserId(){
        String uesrname = getUserName();
        int userid = Db.queryInt("select user_id from user where user_name = ?", getUserName());
        return userid;
    }
}
